/*    */ package cc.s2m.web.s2mBlog.controller;
/*    */ 
/*    */ import cc.s2m.web.s2mBlog.controller.base.BaseController;
/*    */ import cc.s2m.web.s2mBlog.pojo.Articles;
/*    */ import cc.s2m.web.s2mBlog.pojo.ArticlesContent;
/*    */ import cc.s2m.web.s2mBlog.pojo.ArticlesTags;
/*    */ import cc.s2m.web.s2mBlog.service.IArticles;
/*    */ import cc.s2m.web.s2mBlog.service.IArticlesContent;
/*    */ import cc.s2m.web.s2mBlog.service.IArticlesTags;
/*    */ import cc.s2m.web.s2mBlog.vo.Expressions;
/*    */ import cc.s2m.web.s2mBlog.vo.VO;
/*    */ import com.google.common.base.Strings;
/*    */ import com.google.common.collect.Lists;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.ui.Model;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ 
/*    */ @Controller
/*    */ public class Blog extends BaseController
/*    */ {
/*    */ 
/*    */   @Autowired
/*    */   private IArticles articlesService;
/*    */ 
/*    */   @Autowired
/*    */   private IArticlesContent articlesContentService;
/*    */ 
/*    */   @Autowired
/*    */   private IArticlesTags articlesTagsService;
/*    */ 
/*    */   @RequestMapping(value={"/blog/{url}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String detail(Model model, @PathVariable String url)
/*    */   {
/* 38 */     if (Strings.isNullOrEmpty(url)) {
/* 39 */       return "404";
/*    */     }
/* 41 */     Articles article = new Articles();
/* 42 */     article.setUrl(url);
/* 43 */     article = (Articles)this.articlesService.getByCondition(article);
/* 44 */     if (article == null) {
/* 45 */       return "404";
/*    */     }
/* 47 */     article.setViews(Integer.valueOf(article.getViews().intValue() + 1));
/* 48 */     this.articlesService.addViewNumber(article.getId().intValue());
/* 49 */     model.addAttribute("bean", article);
/* 50 */     ArticlesContent content = (ArticlesContent)this.articlesContentService.selectByPrimaryKey(article.getId());
/* 51 */     model.addAttribute("content", content);
/*    */ 
/* 53 */     VO vo = new VO();
/* 54 */     vo.and(Expressions.lt("id", article.getId()));
/* 55 */     Articles preArt = (Articles)this.articlesService.getByCondition(new Articles(), vo);
/* 56 */     model.addAttribute("preArt", preArt);
/*    */ 
/* 58 */     vo = new VO();
/* 59 */     vo.and(Expressions.gt("id", article.getId()));
/* 60 */     Articles nextArt = (Articles)this.articlesService.getByCondition(new Articles(), vo, "id ASC");
/* 61 */     model.addAttribute("nextArt", nextArt);
/*    */ 
/* 63 */     List linkedArtIds = Lists.newArrayList();
/* 64 */     ArticlesTags atagVO = new ArticlesTags();
/* 65 */     atagVO.setAid(article.getId());
/* 66 */     List<ArticlesTags> atags = this.articlesTagsService.getList(atagVO, null);
/* 67 */     if (!atags.isEmpty()) {
/* 68 */       for (ArticlesTags atag : atags) {
/* 69 */         atagVO = new ArticlesTags();
/* 70 */         atagVO.setTid(atag.getTid());
/* 71 */         List<ArticlesTags> atags_ = this.articlesTagsService.getList(atagVO, null);
/* 72 */         for (ArticlesTags atag_ : atags_) {
/* 73 */           if (!linkedArtIds.contains(atag_.getAid())) {
/* 74 */             linkedArtIds.add(atag_.getAid());
/*    */           }
/*    */         }
/*    */       }
/*    */     }
/* 79 */     Map map = new HashMap();
/* 80 */     vo = new VO();
/* 81 */     vo.and(Expressions.in("id", linkedArtIds));
/* 82 */     vo.and(Expressions.ne("id", article.getId()));
/* 83 */     map.put("vo", vo);
/* 84 */     map.put("pageSize", Integer.valueOf(10));
/* 85 */     List linkedArts = this.articlesService.getList(null, map);
/* 86 */     model.addAttribute("linkedArts", linkedArts);
/* 87 */     return "detail";
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.controller.Blog
 * JD-Core Version:    0.6.1
 */